<template>
  <view class="student-list commonDiv">
    <u-navbar
      leftText="返回"
      title="学生信息查询"
      :safeAreaInsetTop="true"
      @leftClick="backPre"
      >
        <view
          class="u-nav-slot"
          slot="right"
          @click="backTo"
        >
        <view class="icon iconfont icon-shouye" style="font-weight: 600;"></view>
      </view>
    </u-navbar>
    <view class="top-box">
      <view>学号：</view>
      <view>
        <u--input
          placeholder="请输入学号"
          border="surround"
          v-model="number"
          confirm-type="search"
          clearable
          @confirm="searchHandle"
          style="width: 200px"
        ></u--input>
      </view>
      <u-button type="primary" icon="search" text="搜索" style="margin: 0 0 0 10px;width: 80px;height: 36px;" @click="searchHandle"></u-button>
    </view>
    <view class="bottom-box">
      <view v-if="studentList.length > 0">
        <studentInfo :tiJianHandleFlag="true" :studentList="studentList" :activeProject="activeProject"></studentInfo>
      </view>
      <view class="empty" v-else>
        <u-empty
          mode="data"
          icon="../../../static/img/noData.png"
        >
      </u-empty>
      </view>
      
    </view>
  </view>
</template>
<script>
import studentInfo from '@/pages/components/studentInfo'
import mRequest from '@/api/index.js'
import hccmStore from '@/common/hccm-store.js'
export default {
  data(){
    return{
      number: '',
      studentList:[],
      activeProject: ''
    }
  },
  components:{studentInfo},
  onLoad(options){
    this.activeProject = options.activeProject
  },
  methods:{
    backPre(){
      uni.navigateBack({
        delta: 1 // delta值为1时表示返回上一级页面
      })
    },
    backTo(){
      uni.reLaunch({
        url: '/pages/home/index'
      })
    },
    searchHandle(){
      mRequest.inspectStudentList({
        limit: 10,
        page: 1,
        number: this.number,
        inspectId: hccmStore.getChooseInspectId()
      }).then(res=>{
        this.studentList = res.data.records
        console.log(res)
      })
    },
  }
}
</script>
<style lang="scss">
  .student-list{
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 100px 20px 20px;
    box-sizing: border-box;
    font-size: 16px;
    .top-box{
      height: 40px;
      padding: 10px 0 10px;
      box-sizing: content-box;
      width: 100%;
      border-bottom: 2px solid #00796bd8;
      display: flex;
      align-items: center;
      justify-content: flex-start;
    }
    .bottom-box{
      flex: 1;
      width: 100%;
      .empty{
        height: 100%;
        box-sizing: border-box;
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: center;
        margin: 0 auto;
      }
    }
  }
</style>